class Restaurant():
    def __init__(self, restaurant_name, cuisine_type):
        self.restaurant_name = restaurant_name
        self.cuisine_type = cuisine_type
    def describe_restaurant(self):
        print("The restaurant's name is "+self.restaurant_name.title())
        print("The restaurant's type is "+self.cuisine_type.title())
    def open_restaurant(self):
        print("The restaurant is opening.")
class IceCreamStand(Restaurant):
    def __init__(self, restaurant_name, cuisine_type):
        super().__init__(restaurant_name, cuisine_type)
        self.flavors = ['巧克力','奥利奥','牛奶','水果']
    def show_IceCream(self):
        for flavor in self.flavors:
            print("The ice-cream's flavors is "+flavor)

icecream = IceCreamStand("bom","Chinese food")
icecream.show_IceCream()

class User():
    def __init__(self, first_name, last_name):
        self.first_name = first_name
        self.last_name = last_name
        # self.age = age
        # self.login_attempts = login_attempts
    def describe_user(self):
        print("User's name is "+self.first_name.title()+" "+self.last_name.title()+","+self.age+".")
    def greet_user(self):
        print("Hello,"+self.first_name.title()+".How are you?")
    def increment_login_attempts(self):
        self.login_attempts += 1
        print("Login_Attempts:"+(str)(self.login_attempts))
    def reset_login_attempts(self):
        self.login_attempts = 0
        print("Login_Attempts:"+(str)(self.login_attempts))

class Privileges():
    def __init__(self):
        self.privileges = ['can add post', 'can delete post', 'can ban user']

    def show_privileges(self):
        print(self.privileges)
class Admin(User):
    def __init__(self, first_name, last_name,):
        super().__init__(first_name, last_name,)
        self.privileges = Privileges()
    def show_privileges(self):
        self.privileges.show_privileges()
admin_1 = Admin("tom","jack")
admin_1.show_privileges()

class Car():
	def __init__(self,make,model,year):
		"""初始化描述汽车的属性"""
		self.make=make
		self.model=model
		self.year=year
		self.odometer_reading=0
		self.miles=0
	def get_desprective_name(self):
		"""返回整洁的描述性信息"""
		long_name=str(self.year)+' '+self.make+' '+self.model
		return long_name.title()
	def read_odometer(self):
		print("This car has "+str(self.odometer_reading)+" miles on it.")
	def update_odometer(self,mileage):
		if mileage>=self.odometer_reading:
			self.odometer_reading=mileage
		else:
			print("You can't roll back an odometer!")
	def increment_odometer(self,miles):
		if miles>=self.miles:
			self.odometer_reading+=miles
		else:
			print("You can't add the miles which is negative number!")
	def fill_gas_tank(self):
		print("This car have a  gas tank")
class Battery():
	def __init__(self,battery_size=70):
		self.battery_size=battery_size
	def describe_battery(self):
		print("This car has a "+str(self.battery_size)+"-kwh battery.")
	def get_range(self):
		if self.battery_size==70:
			range=240
		elif self.battery_size==85:
			range=270
		message="This car can go approximately "+str(range)
		message+=" miles on a full charge."
		print(message)
	def upgrade_battery(self):
		if self.battery_size != 85:
			self.battery_size = 85
class ElectricCar(Car):
	def __init__(self,make,model,age):
		super(ElectricCar,self).__init__(make,model,age)
		self.battery=Battery()
	def fill_gas_tank(self):
		print("This car doesn't have a gas tank!")
my_elsctic=ElectricCar('tesla','model s','2016')
print(my_elsctic.get_desprective_name())
my_elsctic.battery.describe_battery()
# 调用get_range()方法
my_elsctic.battery.get_range()
my_elsctic.battery.upgrade_battery()
# 再次调用get_range()方法
my_elsctic.battery.get_range()
my_elsctic.fill_gas_tank()
